const s = {
  v: `
          attribute vec4 a_position;
          attribute float a_deg;
          void main() {
              gl_Position.x = a_position.x * cos(a_deg) - a_position.y * sin(a_deg);
              gl_Position.y = a_position.x * sin(a_deg) + a_position.y * cos(a_deg);
              gl_Position.z = a_position.z;
              gl_Position.w = a_position.w;
          }
      `,
  f: `
      precision mediump float;
      void main() {
          gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
      }
      `,
}
// 得到着色器程序
const program = getProgram(gl, s)
// // 获取着色器程序中的变量
const a_position = gl.getAttribLocation(program, "a_position")
const a_deg = gl.getAttribLocation(program, "a_deg")
// //TODO 创建顶点数据
const positionData = new Float32Array([
  -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5,
])
// // 创建缓冲对象
const buffer = gl.createBuffer()
// // 绑定缓冲对象
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
// // 填充缓冲对象
gl.bufferData(gl.ARRAY_BUFFER, positionData, gl.STATIC_DRAW)
// // 配置变量
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 0, 0)
// // 启用变量
gl.enableVertexAttribArray(a_position)
let x = -1

// 动画循环
function animate() {
  x += 0.1
  gl.vertexAttrib1f(a_deg, x)
  gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)
  requestAnimationFrame(animate)
}
animate()
